package com.atguigu.srb.sms.utils;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @Description:
 * @Author: Gavin
 * @Date: 7/5/2023 10:47 PM
 */
@Configuration
@Data
@ConfigurationProperties(prefix = "aliyun.sms")
//给bean的声明周期里面加入初始化的内容
public class SmsProperties implements InitializingBean {
    private String host;
    private String path;
    private String method;
    private String appcode;
    private String registryTemplateId;

    private String expire_at;

    public static String HOST;
    public static String PATH;
    public static String METHOD;
    public static String APPCODE;
    public static String REGISTRY_TEMPLATE_ID;

    public static String EXPIRE_AT;


    //这个方法是IOC容器初始化完后,bean的属性都设置结束之后执行的,此时我们将bean的属性设置给静态属性
    @Override
    public void afterPropertiesSet() throws Exception {
        HOST = this.host;
        PATH = this.path;
        METHOD = this.method;
        APPCODE = this.appcode;
        REGISTRY_TEMPLATE_ID = this.registryTemplateId;
        EXPIRE_AT = this.expire_at;
    }
}
